###
#Content Analysis Assessment
###

library(plyr)
library(xtable)

##
#Inter-coder Reliability Analysis
##

load('coder.comparison.RData')

coder.comparison$label.agreement <- ifelse(coder.comparison$label.1==coder.comparison$label.2, 1, 0)
coder.comparison$election.admin.agreement <- ifelse(coder.comparison$election.admin.1==coder.comparison$election.admin.2, 1, 0)
coder.comparison$debunk.agreement <- ifelse(coder.comparison$debunk.1==coder.comparison$debunk.2, 1, 0)

mean(coder.comparison$label.agreement,na.rm=TRUE)
mean(coder.comparison$election.admin.agreement,na.rm=TRUE)
mean(coder.comparison$debunk.agreement,na.rm=TRUE)

##
#Content By Article Analysis
##

load('labeled.articles.RData')

coverage.summary <- ddply(labeled.articles,.(Label),summarise,share=length(Label)/100,focus=mean(focus,na.rm=TRUE),debunk=mean(debunk,na.rm=TRUE),admin=mean(election.admin,na.rm=TRUE))
coverage.summary <- na.omit(coverage.summary)
coverage.summary <- coverage.summary[order(coverage.summary$share,decreasing=TRUE),]
coverage.summary[,2:dim(coverage.summary)[2]] <- round(coverage.summary[,2:dim(coverage.summary)[2]],digits=2)
names(coverage.summary) <- c('Coverage Type','Share','Election Denial Focus','Debunk Claims','Admin Quote')
coverage.summary$'Coverage Type' <- c('Stenography','Strategy Frame','Democracy Frame')
rownames(coverage.summary) <- 1:3
xtable(coverage.summary)
